package com.lucaswangdev;

import com.lucaswangdev.role.AdminRole;
import com.lucaswangdev.role.UserRole;
import com.lucaswangdev.role.UserRoleNormal;

public class NotificationService {

    public static void main(String[] args) {
        // 模拟数据库查询出的实体
        Entity dbEntity = new Entity("Old Remark", false);

        // 模拟请求中的实体
        Entity requestEntity = new Entity("New Remark", true);

        // 创建通知服务
        NotificationService service = new NotificationService();

        // 触发角色变更处理
       service.testHandleChanges("admin", requestEntity, dbEntity);
        // service.testHandleChanges("user", requestEntity, dbEntity);
    }

    /**
     * 私有方法，用于根据角色类型判断并执行相应的变更处理。
     */
    private void testHandleChanges(String roleType, Entity requestEntity, Entity dbEntity) {
        UserRole role;
        switch (roleType.toLowerCase()) {
            case "admin":
                role = new AdminRole();
                break;
            case "user":
                role = new UserRoleNormal();
                break;
            default:
                throw new IllegalArgumentException("Unknown role type: " + roleType);
        }

        // 执行角色对应的变更处理逻辑
        role.handleChanges(requestEntity, dbEntity);
    }
}

